package leijiazaiqi;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @Author Zhouchb
 * @Create 2021-10-2021/10/24 :16:00
 * @Description
 */
public class ClassLoaderTest {
    public static void main(String[] args) throws IOException {
        //对于自定义类，使用系统类加载器进行加载
        ClassLoader classLoader = ClassLoaderTest.class.getClassLoader();
        System.out.println(classLoader);//        sun.misc.Launcher$AppClassLoader@18b4aac2
        //调用系统类加载器的.getParent()：获取扩展类加载器
        ClassLoader parent = classLoader.getParent();
        System.out.println(parent);//        sun.misc.Launcher$ExtClassLoader@4554617c
        //调用扩展类加载器.getParent()无法获取引导类加载器
        //引导类加载器主要负责加载java核心类库，无法加载自定义类
        ClassLoader parent1 = parent.getParent();
        System.out.println(parent1);//        null

        //************加载配置文件
        Properties properties = new Properties();
        InputStream is = classLoader.getResourceAsStream("jdbc.properties");
        properties.load(is);
        String name = properties.getProperty("name");
        String skill = properties.getProperty("skill");
        System.out.println(name);
        System.out.println(skill);
    }

}
